import { IColor } from "@/enum/shape.enum";
import { IType } from "@/interface/IShape";
import { BaseShape } from "./BaseShape";

export class Qrcode extends BaseShape {
  /* 预览图片,在上传的时候需要删除 */
  src: string;

  /* 二维码的文本 */
  text: string;

  /* 二维码的大小 */
  size: number;

  bgcolor: IColor;

  /* 里面的颜色 */
  textColor: IColor;

  /* 边距 */
  margin: number;

  /* 错误等级 */
  errorCorrectionLevel: string;

  constructor() {
    super();
    this.src = "";
    this.text = "1010";
    this.size = 40;
    this.bgcolor = IColor.WHITE;
    this.textColor = IColor.BLACK;
    this.margin = 0;
    this.errorCorrectionLevel = "H";
    this.w = this.size;
    this.h = this.size;
    this.type = IType.QRCODE;
    this.lockAspectRatio = true;
    this.handles = ["tr", "tl", "bl", "br"];
  }
}

/* 动态二维码 */
export class DQrcode extends Qrcode {
  size: number;

  constructor() {
    super();
    this.size = 40;
    this.type = IType.DQRCODE;
    this.handles = ["tr", "tl", "bl", "br"];
  }
}
